package cn.softwin.controller.linkman;

import cn.softwin.pojo.LinkMan;
import cn.softwin.service.impl.CustumerServiceImpl;
import cn.softwin.service.impl.LinkManServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class AddcstCustomerDetailServlet
 */
@WebServlet("/AddLinkManServlet")
public class AddLinkManServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddLinkManServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * Description:
     * Author: zhangxiangkai
     * Params: [request, response]
     * ReturnType: void
     * Time: 2021/2/18-11:38
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request, response);
    }

    /**
     * Description:
     * Author: zhangxiangkai
     * Params: [request, response]
     * ReturnType: void
     * Time: 2021/2/18-11:37
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");//客户端往服务端传输
        LinkMan linkManName = new LinkMan();
        String lkmName = request.getParameter("lkmName");
        linkManName.setLkmName(lkmName);
        String lkmGender=request.getParameter("lkmGender");
        linkManName.setLkmGender(lkmGender);
        String lkmPhone=request.getParameter("lkmPhone");
        linkManName.setLkmPhone(lkmPhone);
        String lkmMobile=request.getParameter("lkmMobile");
        linkManName.setLkmMobile(lkmMobile);
        String lkmEmail = request.getParameter("lkmEmail");
        linkManName.setLkmEmail(lkmEmail);
        String lkmQQ = request.getParameter("lkmQQ");
        linkManName.setLkmQQ(lkmQQ);
        String lkmPosition = request.getParameter("lkmPosition");
        linkManName.setLkmPosition(lkmPosition);
        String lkmMemo = request.getParameter("lkmMemo");
        linkManName.setLkmMemo(lkmMemo);

        //提交到数据库
        LinkManServiceImpl linkManService = new LinkManServiceImpl();
        boolean flag1 = linkManService.addLinkMan(linkManName);
        if(flag1) {
            System.out.println("添加成功");
            request.getRequestDispatcher("success.jsp").forward(request, response);
        }else {
            System.out.println("失败");
        }


    }
}
